home *** CD-ROM | disk | FTP | other *** search
/ 3D GFX / 3D GFX.iso / pcutils / windows / genesis / include / maths.h < prev    next >
C/C++ Source or Header  |  1995-12-30  |  4KB  |  99 lines

  1. /*------------------------------------------------------------------
  2.             Maths Library
  3.             -------------
  4.  
  5.     Header for C implementation of basic geometry related
  6.     maths functions
  7.  
  8.     (C) Silicon Dream Ltd 1994
  9.  
  10.   ------------------------------------------------------------------
  11.  
  12. Changes:                        Date:
  13. * Created file                        17/08/94
  14. */
  15.  
  16. #ifndef MATHS
  17. #define MATHS
  18.  
  19. #include <atomic.h>
  20.  
  21. /* Comonly used constants */
  22.  
  23. #define PI        3.141592654
  24. #define TWO_PI        (2.0*PI)
  25. #define HALF_PI        (0.5*PI)
  26. #define DEG2RAD(x)    ((float) (x)*TWO_PI/360.0)
  27. #define RAD2DEG(x)    ((float) (x)*360.0/TWO_PI)
  28. #define ZERO_TOL    0.000001
  29.  
  30. /* General typedefs */
  31.  
  32. typedef struct Vectortag        /* vec */
  33.     {
  34.     float        fX;
  35.     float        fY;
  36.     float        fZ;
  37.     } Vector;
  38.  
  39. typedef struct LongVectag        /* lvec */
  40.     {
  41.     float        fX;
  42.     float        fY;
  43.     float        fZ;
  44.     float        fW;
  45.     } LongVec;
  46.  
  47. /* For performance reasons (see MthTransLVec routine), we ensure that when we
  48.    store data in a matrix, we must treat the first index as a column index */
  49.  
  50. typedef float        Matrix[4][4];    /* mat */
  51.  
  52. /* Functions */
  53.  
  54. float _dyn MthSqr (float fN);
  55. void _dyn MthConvToPolar (Vector *pvec, float *pfTheta,
  56.               float *pfPhi, float *pfRho);
  57. void _dyn MthConvToCart (Vector *pvec, float fTheta,
  58.              float fPhi, float fRho);
  59. void _dyn MthMakeVec (Vector *pvec, float fX, float fY, float fZ);
  60. bool _dyn MthVecsEqual (Vector *pvecA, Vector *pvecB);
  61. void _dyn MthMakeLVec (LongVec *plvec, float fX, float fY,
  62.                float fZ, float fW);
  63. bool _dyn MthLVecsEqual (LongVec *plvecA, LongVec *plvecB);
  64. void _dyn MthTransVec (Vector *pvec, Matrix mat);
  65. void _dyn MthTransLVec (LongVec *plvec, Matrix mat);
  66. void _dyn MthTransMatrix (Matrix matA, Matrix matB, Matrix matRes);
  67. void _dyn MthAddVec (Vector *pvecA, Vector *pvecB, Vector *pvecRes);
  68. void _dyn MthSubVec (Vector *pvecA, Vector *pvecB, Vector *pvecRes);
  69. void _dyn MthScaleVec (Vector *pvec, float fScale);
  70. float _dyn MthLenVec (Vector *pvec);
  71. void _dyn MthCrossProd (Vector *pvecA, Vector *pvecB, Vector *pvecRes);
  72. float _dyn MthDotProd (Vector *pvecA, Vector *pvecB);
  73. bool _dyn MthMatsEqual (Matrix matA, Matrix matB);
  74. void _dyn MthSetMat (Matrix mat, float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, float f10, float f11, float f12, float f13, float f14, float f15, float f16);
  75. void _dyn MthGetIdentMat (Matrix mat);
  76. void _dyn MthGetXrotMat (Matrix mat, float fAng);
  77. void _dyn MthGetYrotMat (Matrix mat, float fAng);
  78. void _dyn MthGetZrotMat (Matrix mat, float fAng);
  79. void _dyn MthGetTranslMat (Matrix mat, Vector *pvec);
  80. void _dyn MthGetScaleMat (Matrix mat, float fX, float fY, float fZ);
  81. bool _dyn MthCompInvMat (Matrix mat, Matrix matInv);
  82. void _dyn MthCompTransMat (Vector *pvecOrg, Vector *pvecAxZ,
  83.                Vector *pvecAxY, Matrix matT);
  84. void _dyn MthTranslParent (Vector *pvec, Matrix matTrans);
  85. void _dyn MthTranslChild (Vector *pvec, Matrix matTrans);
  86. void _dyn MthScaleParent (float fX, float fY, float fZ, Matrix matTrans);
  87. void _dyn MthScaleChild (float fX, float fY, float fZ, Matrix matTrans);
  88. void _dyn MthXrotParent (float fAng, Matrix matTrans);
  89. void _dyn MthYrotParent (float fAng, Matrix matTrans);
  90. void _dyn MthZrotParent (float fAng, Matrix matTrans);
  91. void _dyn MthXrotChild (float fAng, Matrix matTrans);
  92. void _dyn MthYrotChild (float fAng, Matrix matTrans);
  93. void _dyn MthZrotChild (float fAng, Matrix matTrans);
  94. void _dyn MthReverseX (Matrix matTrans);
  95. void _dyn MthReverseY (Matrix matTrans);
  96. void _dyn MthReverseZ (Matrix matTrans);
  97.  
  98. #endif            // Do not include this file twice
  99.